package com.example.shop_2304.minefg

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.blankj.utilcode.util.ToastUtils
import com.example.base.mvvm.BaseFragment
import com.example.shop_2304.R
import com.example.shop_2304.adapter.OrderAdapter
import com.example.shop_2304.databinding.FragmentPay2Binding
import com.example.shop_2304.databinding.FragmentPay5Binding


class Pay5Fragment  : BaseFragment<FragmentPay5Binding, PayViewModel>() {
    lateinit var orderAdapter: OrderAdapter
    override fun initView() {
        orderAdapter = OrderAdapter()
        binding.rv.adapter = orderAdapter
        binding.rv.layoutManager = LinearLayoutManager(context)

        viewModel.order("-3",10,1)
    }

    override fun initData() {
        viewModel.success.observe(this){
            if(it.code==200){
                orderAdapter.data.clear()
                orderAdapter.data.addAll(it.data.list)
                orderAdapter.notifyDataSetChanged()
            }else{
                ToastUtils.showLong(it.message)
            }
        }
    }

    override fun getLayout(): Int = R.layout.fragment_pay5

    override fun getViewModel(): Class<PayViewModel>  = PayViewModel::class.java

}